package com.nidu.demo.common.enums;

import cn.hutool.core.util.ArrayUtil;
import com.nidu.demo.common.validation.IntArrayValuable;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;

@Getter
@AllArgsConstructor
public enum MenuTypeEnum implements IntArrayValuable {
    DIRECTORY(1, "目录"),

    MENU(2, "菜单"),

    BUTTON(3, "按钮");

    private final Integer type;

    private final String desc;

    public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(MenuTypeEnum::getType).toArray();

    @Override
    public int[] array() {
        return ARRAYS;
    }

    public static MenuTypeEnum of(Integer val) {
        return ArrayUtil.firstMatch(o -> o.getType().equals(val), values());
    }
} 